﻿<UserControl x:Class="WFDataBaseProject.Controls.UCParametersCollectionEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             Name="ParentControl"
             xmlns:helpers="clr-namespace:WFDataBaseProject.Helpers"
             xmlns:controls="clr-namespace:WFDataBaseProject.Controls"
             Loaded="UserControl_Loaded"
             Width="500" Height="500">  
    <UserControl.Resources>
        <helpers:SQLTypes x:Key="sqltypes"/>
        <DataTemplate x:Key="templatelist">
            <Border BorderBrush="Black" BorderThickness="1">
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock  Text="Parameter name:  "/>
                        <TextBlock Text="{Binding Path=ParameterName}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock  Text="Parameter type:  "/>
                        <TextBlock Grid.Column="1" Text="{Binding Path=DbType}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock  Text="Parameter direction:  "/>
                        <TextBlock Grid.Column="2" Text="{Binding Path=Direction}" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock  Text="Parameter value:  "/>
                        <TextBlock Grid.Column="3" Text="{Binding Path=Value}" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock  Text="Parameter size:  "/>
                        <TextBlock Grid.Column="4" Text="{Binding Path=Size}" />
                    </StackPanel>
                </StackPanel>
            </Border>
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="3*" />
            <RowDefinition Height=".25*" />
            <RowDefinition Height=".4*" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <!--Parameter name-->
            <TextBlock Text="Parameter name:" Grid.Row="0" Grid.Column="0"/>
            <Border BorderThickness="1" BorderBrush="Black"
                    Margin="1,1,1,1" Grid.Row="1" Grid.Column="0">
                <TextBox  Name="txtParamname"/>
            </Border>
            <!--Parameter type-->
            <TextBlock Text="Parameter type:" Grid.Row="0" Grid.Column="1"/> 
                <ComboBox  Name="cmbParamtype" Margin="1,1,1,1" ItemsSource="{StaticResource sqltypes}"
                           Grid.Row="1" Grid.Column="1"/>
            <!--Parameter direction-->
            <TextBlock Text="Direction:" Grid.Row="0" Grid.Column="2"/>
            <ComboBox  Name="cmbParamdirection" Margin="1,1,1,1" Grid.Row="1" Grid.Column="2">
                <ComboBoxItem>Input</ComboBoxItem>
                <ComboBoxItem>Output</ComboBoxItem>
                <ComboBoxItem>InputOutput</ComboBoxItem>
                <ComboBoxItem>Returned Value</ComboBoxItem>
            </ComboBox>
            <!--Parameter value-->
            <TextBlock Text="Parameter Value:" Grid.Row="0" Grid.Column="3"/>
            <Border BorderThickness="1" BorderBrush="Black"
                    Margin="1,1,1,1" Grid.Row="1" Grid.Column="3">
                <TextBox  Name="txtParamvalue"/>
            </Border>
            <!--Parameter size-->
            <TextBlock Text="Parameter size:" Grid.Row="0" Grid.Column="4"/>
            <Border BorderThickness="1" BorderBrush="Black"
                    Margin="1,1,1,1" Grid.Row="1" Grid.Column="4">
                <TextBox  Name="txtParamsize"/>
            </Border>
            <!--Add button-->
            <Button Content="Add" Name="btnAdd" Grid.Row="3" Grid.Column="3" Margin="1,1,1,1" Click="btnAdd_Click" />
            <!--Clear button-->
            <Button Content="Clear" Name="btnClear" Grid.Row="3" Grid.Column="4" Margin="1,1,1,1" Click="btnClear_Click" />
        </Grid>
        <!--List box-->                                                                                                                                                         
        <Border BorderThickness="1" BorderBrush="Black" Grid.Row="1" Margin="5,5,5,5">
            <ListBox Name="lstParameters" ItemTemplate="{StaticResource templatelist}">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <UniformGrid/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
        </Border>
        
        <TextBlock Text="Select a parameter to be updated or deleted" Grid.Row="2"/>
        <!--The footer-->
        <Grid Grid.Row="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition Width="2*"/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button Content="Update" Name="btnUpdate" Grid.Column="0" Margin="5,10,5,10" Click="btnUpdate_Click" />
            <Button Content="Delete" Name="btnDelete" Grid.Column="1" Margin="5,10,5,10" Click="btnDelete_Click" />
            <Button Content="OK" Name="btnOK" Grid.Column="3" Margin="5,10,5,10" Click="btnOK_Click" />
            <Button Content="Cancel" Name="btnCancel" Grid.Column="4" Margin="5,10,5,10" Click="btnCancel_Click" />
        </Grid>
    </Grid>
</UserControl>
